import axios from 'axios'
import * as constants from './constants'
// import { fromJS } from 'immutable'
const changeLoginState = (account, password) => ({
  type: constants.CHANGE_LOGIN,
  value: true
})

export const logout = () => ({
  type: constants.CHANGE_LOGIN,
  value: false
})

export const login = (account, password) => {
  return (dispatch) => {
    axios.get('/api/login.json?account=' + account + '&password' + password).then((res) => {
      const result = res.data.data;
      if (result) {
        dispatch(changeLoginState())
      } else {
        alert('登陆失败')
      }

    })
  }
}